package com.cssy.xxkj.logic.dao.impl;

import java.util.List;
import java.util.Map;

import org.springframework.dao.DataAccessException;
import org.springframework.orm.ibatis.support.SqlMapClientDaoSupport;

import com.cssy.xxkj.logic.dao.LogicWarehouseMaterialoutItemDAO;
import com.cssy.xxkj.logic.entity.LogicWarehouseMaterialoutItemDO;
import com.plat.helper.SearchConditions;

/**
 * 数据访问对象实现类
 * @since 2014-10-29
 */
public class LogicWarehouseMaterialoutItemDAOImpl extends SqlMapClientDaoSupport implements LogicWarehouseMaterialoutItemDAO {

    /**
     * 插入数据
     * @param logicWarehouseMaterialoutItemDO
     * @return 插入数据的主键
     */
    public String insertLogicWarehouseMaterialoutItemDO(LogicWarehouseMaterialoutItemDO logicWarehouseMaterialoutItemDO) throws DataAccessException {
        Object id = getSqlMapClientTemplate().insert("LogicWarehouseMaterialoutItem.insert", logicWarehouseMaterialoutItemDO);
        return (String) id;
    }

    /**
     * 统计记录数
     * @param logicWarehouseMaterialoutItemDO
     * @return 查出的记录数
     */
    public Integer countLogicWarehouseMaterialoutItemDOByExample(LogicWarehouseMaterialoutItemDO logicWarehouseMaterialoutItemDO) throws DataAccessException {
        Integer count = (Integer) getSqlMapClientTemplate().queryForObject("LogicWarehouseMaterialoutItem.countByDOExample", logicWarehouseMaterialoutItemDO);
        return count;
    }

    /**
     * 更新记录
     * @param logicWarehouseMaterialoutItemDO
     * @return 受影响的行数
     */
    public Integer updateLogicWarehouseMaterialoutItemDO(LogicWarehouseMaterialoutItemDO logicWarehouseMaterialoutItemDO) throws DataAccessException {
        int result = getSqlMapClientTemplate().update("LogicWarehouseMaterialoutItem.update", logicWarehouseMaterialoutItemDO);
        return result;
    }

    /**
     * 获取对象列表
     * @param logicWarehouseMaterialoutItemDO
     * @return 对象列表
     */
    @SuppressWarnings("unchecked")
    public List<LogicWarehouseMaterialoutItemDO> findListByExample(LogicWarehouseMaterialoutItemDO logicWarehouseMaterialoutItemDO) throws DataAccessException {
        List<LogicWarehouseMaterialoutItemDO> list = getSqlMapClientTemplate().queryForList("LogicWarehouseMaterialoutItem.findListByDO", logicWarehouseMaterialoutItemDO);
        return list;
    }
    
    public List<LogicWarehouseMaterialoutItemDO> findListByMap(Map<String, Object> paramMap) throws DataAccessException {
    	List<LogicWarehouseMaterialoutItemDO> list = getSqlMapClientTemplate().queryForList("LogicWarehouseMaterialoutItem_ex.findListByMap", paramMap);
        return list;
    }

    /**
     * 根据主键获取logicWarehouseMaterialoutItemDO
     * @param id
     * @return logicWarehouseMaterialoutItemDO
     */
    public LogicWarehouseMaterialoutItemDO findLogicWarehouseMaterialoutItemDOByPrimaryKey(String id) throws DataAccessException {
        LogicWarehouseMaterialoutItemDO logicWarehouseMaterialoutItemDO = (LogicWarehouseMaterialoutItemDO) getSqlMapClientTemplate().queryForObject("LogicWarehouseMaterialoutItem.findByPrimaryKey", id);
        return logicWarehouseMaterialoutItemDO;
    }

    /**
     * 删除记录
     * @param id
     * @return 受影响的行数
     */
    public Integer deleteLogicWarehouseMaterialoutItemDOByPrimaryKey(String id) throws DataAccessException {
        Integer rows = (Integer) getSqlMapClientTemplate().delete("LogicWarehouseMaterialoutItem.deleteByPrimaryKey", id);
        return rows;
    }


	@Override
	public List<LogicWarehouseMaterialoutItemDO> findByPid(String pid) {
		List<LogicWarehouseMaterialoutItemDO> list = getSqlMapClientTemplate().queryForList("LogicWarehouseMaterialoutItem_ex.findByPid", pid);
        return list;
	}

	@Override
	public Integer deleteByPid(String id) {
		Integer rows = (Integer) getSqlMapClientTemplate().delete("LogicWarehouseMaterialoutItem_ex.deleteByPid", id);
        return rows;
	}

	@Override
	public List<LogicWarehouseMaterialoutItemDO> finListByCondition(
			SearchConditions scs) throws DataAccessException {
		return getSqlMapClientTemplate().queryForList("LogicWarehouseMaterialoutItem_ex.findList", scs);
	}


}